<?php
/**
 * 会员等级操作
 * @author hushuai
 *
 */
class LevelAction extends CommonAction {
	
	/**
	 * 初始化
	 */
	public function _initialize(){
	
		parent::_initialize();
		//parent::checkTimestamp();
	}
	
	/**
	 * 会员卡列表
	 * retrun array
	 */
	public function index(){
		 
		$map['isdel'] = $this->_get("isdel","intval",1);
		
		$this->success(D('Level')->listAll($map));
	}
	
	/**
     * 修改会员等级
     * @param int $id   会员卡编号
     */
    public function edit(){
    	
    	if(IS_GET){
    		
    		$id   = $this->_get("id",  "intval",0);
    		$this->success(D('Level')->find($id));
    	}else{
    		
    		parent::do_edit("Vipcard");
    	}
    	
    
    }
    /**
     * 会员等级调整
     * @param  $id      int   会员卡关用户关联表主键
     * @param  $cardid  int   会员卡编号
     * return  boolean
     */
    public function move(){
    	
    	$map['id']       = $this->_get("id",      "trim",  "");
    	$map['cardid']   = $this->_get("cardid",  "intval",0);
    	$map['cardname'] = $this->_get("cardname","trim",  "");
    	
    	$flag  = D('Level')->move($map);
    	if($flag){
    		$this->success("调整成功！");
    	}else{
    		$this->error("调整失败！");
    	}
    }
    /**
     * 增加会员等级
     */
    public function add(){
    	
    	$param = array(
    			"after" => "Vipcard_after_deal",
    	);
    	parent::do_add("Vipcard",$param);
    
    }
    
     /**
     * 删除会员等级
     */
    public function del(){
    	
    	parent::do_del("Vipcard",      true);   //删除会员等级表中相关数据
/*     	parent::do_del("vipcardUser",  true);	//删除会员等级表中相关数据
    	parent::do_del("vipcardCredit",true);   //删除积分操作记录表中相关数据
    	parent::do_del("vipcardMoney", true);	//删除金额操作记录表中相关数据 */
    }
}